const express = require('express')

const app = express()

const mw = (req, res, next) => {
  console.log('局部生效的中间件')
  next()
}

// 局部注册的中间件函数，只对指定的路由生效
app.get('/', mw, (req, res) => { 
  res.send('Home page.')
  console.log('访问了/路径')
})

app.get('/user', mw, (req, res) => { 
  res.send('user page.')
  console.log('访问了/user路径')
})

app.listen(80, () => {
  console.log('express server running at http://127.0.0.1')
})